import { http } from "@/utils/http";
/**
 * @description 获取商品列表
 * @param data {page, pageSize, goodsName, categoryId, goodsType, isBestseller, onSale, isHome}
 * @returns
 */
export const getProducts = (data?: any) => {
  return http.request("post", "/admin/goods/product/list", { data });
};
/**
 * @description 获取商品分类列表
 * @returns
 */
export const getCats = () => {
  return http.request("post", "/admin/goods/category/list");
};
/**
 * @description 添加分类
 */
export const addCat = (data?: any) => {
  return http.request("post", "/admin/goods/category/add", { data });
};
/**
 * @description 修改分类
 */
export const setCat = (data?: any) => {
  return http.request("post", "/admin/goods/category/set", { data });
};
/**
 * @description 添加商品
 */
export const addProductInfo = (data?: any) => {
  return http.request("post", "/admin/goods/goods/add", { data });
};
/**
 * @description 修改商品
 */
export const setProductInfo = (data_?: any) => {
  const data = Object.assign({}, data_);
  const id = data?.id;
  delete data?.id;
  return http.request("post", `/admin/goods/set/${id}`, { data });
};
/**
 * @description 商品详情
 */
export const getProductInfo = (pId: number) => {
  return http.request("get", `/admin/goods/info/${pId}`);
};
/**
 * @description 下架上架
 */
export const setProductSale = (pId: number) => {
  return http.request("post", `/admin/goods/sale/${pId}`);
};
/**
 * 
 * @param data 获取订单列表
 * @returns 
 * {
    "keyWord": "string",
    "startTime": "date",
    "orderStatus": "integer",
    "no": "string",
    "page": "integer",
    "pageSize": "integer"
}
 */
export const getOrders = (data?: any) => {
  return http.request("post", "/admin/order/order/list", { data });
};
/**
 *
 * @param data 获取订单详情
 * @returns
 */
export const getOrderInfo = (id: number) => {
  return http.request("post", `/admin/order/info/${id}`);
};
/**
 *
 * @param data 发货
 * @returns
 * {
    "shipCompany":"",
    "shipNo":"",
    "shipImage":""
}
 */
export const setOrderShip = (data: any) => {
  const id = data?.id;
  delete data?.id;
  return http.request("post", `/admin/order/ship/${id}`, { data });
};
